-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(react-motion): add useMotion hook #28699
feat(react-motion): add useMotion hook #28699
Conversation
📊 Bundle size reportUnchanged fixtures
|
Perf Analysis (
|
Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
---|---|---|---|---|---|
Avatar | mount | 660 | 620 | 5000 | |
Button | mount | 316 | 317 | 5000 | |
Field | mount | 1119 | 1095 | 5000 | |
FluentProvider | mount | 675 | 681 | 5000 | |
FluentProviderWithTheme | mount | 78 | 80 | 10 | |
FluentProviderWithTheme | virtual-rerender | 63 | 74 | 10 | |
FluentProviderWithTheme | virtual-rerender-with-unmount | 68 | 80 | 10 | |
InfoButton | mount | 13 | 12 | 5000 | |
MakeStyles | mount | 872 | 856 | 50000 | |
Persona | mount | 1728 | 1722 | 5000 | |
SpinButton | mount | 1367 | 1342 | 5000 |
🕵 fluentuiv9 No visual regressions between this PR and main |
packages/react-components/react-utilities/src/hooks/useMotionPresence.ts
Outdated
Show resolved
Hide resolved
packages/react-components/react-utilities/src/hooks/useMotionPresence.ts
Outdated
Show resolved
Hide resolved
packages/react-components/react-utilities/src/hooks/useMotionPresence.ts
Outdated
Show resolved
Hide resolved
… presence requestAnimationFrame
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 83ef7e1:
|
Asset size changesSize Auditor did not detect a change in bundle size for any component! Baseline commit: 2147e3d60a21ff7ded34b27a19f3d5313533e910 (build) |
* master: chore(cxe-prg): migrate to new slot API (microsoft#28752) chore(teams-prg): migrate to new slot API (microsoft#28751) chore: re-export slot and assertSlots methods (microsoft#28755) Docs(react-tree): Improve docs and stories (microsoft#28741) feat: implements nested tree selection (microsoft#28668) applying package updates applying package updates feature(react-utilities): implements new slot methods (`slot` and `assertSlots`) (microsoft#28373) fix(TimePicker): Selection now works in locales that don't use "am"/"pm" in their time format (microsoft#28469) bugfix: ensures controlled state works properly + (microsoft#28665) feat(tokens): Add status color tokens (microsoft#28006) feat(tokens): Add colorBrandStroke2Contrast and colorNeutralStrokeAlpha2 (microsoft#28638) Made BreadcrumbButton consistent with Item and Link (microsoft#28672)
packages/react-components/react-utilities/src/hooks/useMotionPresence.ts
Outdated
Show resolved
Hide resolved
* master: chore: update CODEOWNERS to some components to tag the current owner (microsoft#28949) fix(react-popover): Only apply modal attributes if the PopoverSurface traps focus (microsoft#28613) feat(react-table, react-components): export DataGridContextProvider (microsoft#28955) chore: decrease bundle size & adds fixtures (microsoft#28962) feat(react-utilities): create useAnimationFrame hook (microsoft#28948) fix(react-utilities): `useOnClickOutside` should consider text selection from inside to outside as inside click (microsoft#28765) docs(react-accordion): Added subcomponents to index story (microsoft#28956) applying package updates bugfix: ensure interop between assertSlots and old API (microsoft#28957) chore: rename imports from react-tree to react-components (microsoft#28946) applying package updates fix: Autofill queries the inputElement ownerDocument instead of document (microsoft#27312)
packages/react-components/react-motion-preview/src/hooks/useMotion.ts
Outdated
Show resolved
Hide resolved
packages/react-components/react-motion-preview/src/hooks/useMotion.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CODEOWNERS file change seems to be unnecessary?! besides that LGTM 👍🏻
Co-authored-by: Bernardo Sunderhus <[email protected]>
* master: feat(react-motion): add useMotion hook (microsoft#28699)
* master: (24 commits) feat(react-motion): add useMotion hook (microsoft#28699) feat: add closeOnIframeFocus prop to Popover (microsoft#28881) chore: updates .devcontainer to follow new format (microsoft#28990) Line Chart and Area Chart - Component tests (microsoft#28235) applying package updates 28576 small button is using 3px border radius (microsoft#28589) In PeoplePicker, we can now use arrow keys to move cursor around microsoft#28655 (microsoft#28975) chore: Migrate bot config to yml (microsoft#28981) fix(react-card): CardHeader grid layout ignoring line-height of content (microsoft#28968) fix(react-tags-preview): tag with secondary text has no top border under windows high contrast (microsoft#28963) applying package updates feat(Stack): Add deprecated flag to render null when receiving a falsy value (microsoft#28978) feat(react-infobutton): Add inline prop to InfoButton and make it inline by default (microsoft#28605) fix(Dialog): Add displayName for dialog footer and content (microsoft#28939) Revert "Keytips: Align keytipData with visible instance for dupes" (microsoft#28977) Vertical stacked bar chart - Component tests (microsoft#28594) docs: update drawer spec to be inline with changes to component (microsoft#28934) Table/DataGrid: fix visuals for overflow (microsoft#28940) Focus indicator bug in bar charts (microsoft#28414) Pie chart focus spacing (microsoft#28504) ...
* master: (24 commits) feat(react-motion): add useMotion hook (microsoft#28699) feat: add closeOnIframeFocus prop to Popover (microsoft#28881) chore: updates .devcontainer to follow new format (microsoft#28990) Line Chart and Area Chart - Component tests (microsoft#28235) applying package updates 28576 small button is using 3px border radius (microsoft#28589) In PeoplePicker, we can now use arrow keys to move cursor around microsoft#28655 (microsoft#28975) chore: Migrate bot config to yml (microsoft#28981) fix(react-card): CardHeader grid layout ignoring line-height of content (microsoft#28968) fix(react-tags-preview): tag with secondary text has no top border under windows high contrast (microsoft#28963) applying package updates feat(Stack): Add deprecated flag to render null when receiving a falsy value (microsoft#28978) feat(react-infobutton): Add inline prop to InfoButton and make it inline by default (microsoft#28605) fix(Dialog): Add displayName for dialog footer and content (microsoft#28939) Revert "Keytips: Align keytipData with visible instance for dupes" (microsoft#28977) Vertical stacked bar chart - Component tests (microsoft#28594) docs: update drawer spec to be inline with changes to component (microsoft#28934) Table/DataGrid: fix visuals for overflow (microsoft#28940) Focus indicator bug in bar charts (microsoft#28414) Pie chart focus spacing (microsoft#28504) ...
* master: (26 commits) chore: Make triage bot add needs triage label to new issues (microsoft#28994) fix(react-tags-preview): use regular icon for dismiss (microsoft#28958) feat(react-motion): add useMotion hook (microsoft#28699) feat: add closeOnIframeFocus prop to Popover (microsoft#28881) chore: updates .devcontainer to follow new format (microsoft#28990) Line Chart and Area Chart - Component tests (microsoft#28235) applying package updates 28576 small button is using 3px border radius (microsoft#28589) In PeoplePicker, we can now use arrow keys to move cursor around microsoft#28655 (microsoft#28975) chore: Migrate bot config to yml (microsoft#28981) fix(react-card): CardHeader grid layout ignoring line-height of content (microsoft#28968) fix(react-tags-preview): tag with secondary text has no top border under windows high contrast (microsoft#28963) applying package updates feat(Stack): Add deprecated flag to render null when receiving a falsy value (microsoft#28978) feat(react-infobutton): Add inline prop to InfoButton and make it inline by default (microsoft#28605) fix(Dialog): Add displayName for dialog footer and content (microsoft#28939) Revert "Keytips: Align keytipData with visible instance for dupes" (microsoft#28977) Vertical stacked bar chart - Component tests (microsoft#28594) docs: update drawer spec to be inline with changes to component (microsoft#28934) Table/DataGrid: fix visuals for overflow (microsoft#28940) ...
This PR implements the
useMotion
hook. This is part of the Component CSS Transitions/Animations on mount/unmount RFC efforts. A preview of the usage of this hook can be found in the feat: implement motion for Drawer PR.This also creates a separate package to deal with motion related code. For now, we have only included one hook, but that can open up to have dedicated components to handle animations/transitions.
Context
Currently, there is a limitation in incorporating motion effects to components during their mounting or unmounting. This restricts the ability to apply CSS motion for components featuring an open/close behavior.
This hook effectively tracks CSS animations/transitions and returns the state of those animations/transitions.
Example
useMotion
also accepts the same value it returns, in caseuseMotion
was called somewhere else. This is extremely useful to avoid double calculation in case partners wants to override a default animation to a component:Return type